package com.magiccompass.alipay.barcode.util;

import com.magiccompass.alipay.barcode.entity.AlipayBarcodeCancelRequest;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeCancelResponse;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodePaymentRequest;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodePaymentResponse;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeQueryRequest;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeQueryResponse;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeRefundRequest;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeRefundResponse;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeReverseRequest;
import com.magiccompass.alipay.barcode.entity.AlipayBarcodeReverseResponse;
import com.magiccompass.alipay.barcode.entity.AlipayQRCodeCreateRequest;
import com.magiccompass.alipay.barcode.entity.AlipayQRCodeCreateResponse;
import com.magiccompass.alipay.barcode.model.AlipayBarcodeBaseResponse;
import com.magiccompass.alipay.barcode.model.AlipayBarcodeCancelResponseModel;
import com.magiccompass.alipay.barcode.model.AlipayBarcodePaymentResponseModel;
import com.magiccompass.alipay.barcode.model.AlipayBarcodeQueryResponseModel;
import com.magiccompass.alipay.barcode.model.AlipayBarcodeRefundResponseModel;
import com.magiccompass.alipay.barcode.model.AlipayBarcodeReverseResponseModel;
import com.magiccompass.alipay.barcode.model.AlipayQRCodeCreateResponseModel;

public class AlipayBarcodeResponseUtil {
	public static AlipayBarcodeBaseResponse createAlipayBarcodeBaseReponseEntityFromModelAndRequest(
			AlipayBarcodePaymentResponseModel model, AlipayBarcodePaymentRequest abr, String responseType){
		AlipayBarcodePaymentResponse abpr = new AlipayBarcodePaymentResponse();
		abpr.setAlipayBarcodePaymentRequest(abr);
		abpr.setAlipayBuyerLoginId(model.getAlipayBuyerLoginId());
		abpr.setAlipayBuyerUserId(model.getAlipayBuyerUserId());
		abpr.setAlipayPayTime(DateTimeUtil.getTimestampFromStringByFormat(model.getAlipayPayTime(), "yyyyMMddHHmmss"));
		abpr.setAlipayTransId(model.getAlipayTransId());
		abpr.setCurrency(model.getCurrency());
		abpr.setError(model.getError());
		abpr.setExchangeRate(model.getExchangeRate());
		abpr.setIsSuccess(model.getIsSuccess());
		abpr.setMerchantTransaction(abr.getMerchantTransaction());
		abpr.setPartnerTransId(model.getPartnerTransId());
		abpr.setResultCode(model.getResultCode());
		abpr.setSign(model.getSign());
		abpr.setSignType(model.getSignType());
		abpr.setTransAmount(model.getTransAmount());
		abpr.setTransAmountCNY(model.getTransAmountCNY());
		return abpr;
	}
	public static AlipayBarcodePaymentResponse createAlipayBarcodePaymentReponseEntityFromModelAndRequest(
			AlipayBarcodePaymentResponseModel model, AlipayBarcodePaymentRequest abr){
		AlipayBarcodePaymentResponse abpr = new AlipayBarcodePaymentResponse();
		abpr.setAlipayBarcodePaymentRequest(abr);
		abpr.setAlipayBuyerLoginId(model.getAlipayBuyerLoginId());
		abpr.setAlipayBuyerUserId(model.getAlipayBuyerUserId());
		abpr.setAlipayPayTime(DateTimeUtil.getTimestampFromStringByFormat(model.getAlipayPayTime(), "yyyyMMddHHmmss"));
		abpr.setAlipayTransId(model.getAlipayTransId());
		abpr.setCurrency(model.getCurrency());
		abpr.setError(model.getError());
		abpr.setExchangeRate(model.getExchangeRate());
		abpr.setIsSuccess(model.getIsSuccess());
		abpr.setMerchantTransaction(abr.getMerchantTransaction());
		abpr.setPartnerTransId(model.getPartnerTransId());
		abpr.setResultCode(model.getResultCode());
		abpr.setSign(model.getSign());
		abpr.setSignType(model.getSignType());
		abpr.setTransAmount(model.getTransAmount());
		abpr.setTransAmountCNY(model.getTransAmountCNY());
		return abpr;
	}
	
	public static AlipayBarcodeQueryResponse createAlipayBarcodeQueryReponseEntityFromModelAndRequest(
			AlipayBarcodeQueryResponseModel model, AlipayBarcodeQueryRequest abqr){
		AlipayBarcodeQueryResponse abpr = new AlipayBarcodeQueryResponse();
		abpr.setAlipayBarcodeQueryRequest(abqr);
		abpr.setAlipayTransStatus(model.getAlipayTransStatus());
		abpr.setAlipayBuyerLoginId(model.getAlipayBuyerLoginId());
		abpr.setAlipayBuyerUserId(model.getAlipayBuyerUserId());
		if(model.getAlipayPayTime()!=null){
			abpr.setAlipayPayTime(DateTimeUtil.getTimestampFromStringByFormat(model.getAlipayPayTime(), "yyyyMMddHHmmss"));
		}
		abpr.setAlipayTransId(model.getAlipayTransId());
		abpr.setCurrency(model.getCurrency());
		abpr.setError(model.getError());
		abpr.setExchangeRate(model.getExchangeRate());
		abpr.setIsSuccess(model.getIsSuccess());
		abpr.setMerchantTransaction(abqr.getMerchantTransaction());
		abpr.setPartnerTransId(model.getPartnerTransId());
		abpr.setResultCode(model.getResultCode());
		abpr.setSign(model.getSign());
		abpr.setSignType(model.getSignType());
		abpr.setTransAmount(model.getTransAmount());
		abpr.setTransAmountCNY(model.getTransAmountCNY());
		return abpr;
	}
	
	public static AlipayBarcodeCancelResponse createAlipayBarcodeCancelReponseEntityFromModelAndRequest(
			AlipayBarcodeCancelResponseModel model, AlipayBarcodeCancelRequest abcreq){
		AlipayBarcodeCancelResponse abcr = new AlipayBarcodeCancelResponse();
		abcr.setAlipayBarcodeCancelRequest(abcreq);
		abcr.setAlipayCancelTime(DateTimeUtil.getTimestampFromStringByFormat(model.getAlipayCancelTime(), "yyyyMMddHHmmss"));
		abcr.setAlipayTransId(model.getAlipayTransId());
		abcr.setError(model.getError());
		abcr.setIsSuccess(model.getIsSuccess());
		abcr.setMerchantTransaction(abcreq.getMerchantTransaction());
		abcr.setPartnerTransId(model.getPartnerTransId());
		abcr.setResultCode(model.getResultCode());
		abcr.setSign(model.getSign());
		abcr.setSignType(model.getSignType());
		return abcr;
	}
	
	public static AlipayBarcodeReverseResponse createAlipayBarcodeReverseReponseEntityFromModelAndRequest(
			AlipayBarcodeReverseResponseModel model, AlipayBarcodeReverseRequest abrreq){
		AlipayBarcodeReverseResponse abcr = new AlipayBarcodeReverseResponse();
		abcr.setAlipayBarcodeReverseRequest(abrreq);
		abcr.setAlipayReverseTime(DateTimeUtil.getTimestampFromStringByFormat(model.getAlipayReverseTime(), "yyyyMMddHHmmss"));
		abcr.setAlipayTransId(model.getAlipayTransId());
		abcr.setError(model.getError());
		abcr.setIsSuccess(model.getIsSuccess());
		abcr.setMerchantTransaction(abrreq.getMerchantTransaction());
		abcr.setPartnerTransId(model.getPartnerTransId());
		abcr.setResultCode(model.getResultCode());
		abcr.setSign(model.getSign());
		abcr.setSignType(model.getSignType());
		return abcr;
	}
	
	public static AlipayBarcodeRefundResponse createAlipayBarcodeRefundReponseEntityFromModelAndRequest(
			AlipayBarcodeRefundResponseModel model, AlipayBarcodeRefundRequest abrreq){
		AlipayBarcodeRefundResponse abrr = new AlipayBarcodeRefundResponse();
		abrr.setAlipayBarcodeRefundRequest(abrreq);
		abrr.setAlipayTransId(model.getAlipayTransId());
		abrr.setError(model.getError());
		abrr.setIsSuccess(model.getIsSuccess());
		abrr.setMerchantTransaction(abrreq.getMerchantTransaction());
		abrr.setPartnerTransId(model.getPartnerTransId());
		abrr.setResultCode(model.getResultCode());
		abrr.setSign(model.getSign());
		abrr.setSignType(model.getSignType());
		abrr.setRefundAmount(model.getRefundAmount());
		abrr.setCurrency(model.getCurrency());
		abrr.setExchangeRate(model.getExchangeRate());
		abrr.setRefundAmountCNY(model.getRefundAmountCNY());
		return abrr;
	}
	
	public static AlipayQRCodeCreateResponse createAlipayQRCodeCreateReponseEntityFromModelAndRequest(
			AlipayQRCodeCreateResponseModel model,AlipayQRCodeCreateRequest aqrccr){
		AlipayQRCodeCreateResponse aqrccres = new AlipayQRCodeCreateResponse();
		aqrccres.setAlipayQRCodeCreateRequest(aqrccr);
		aqrccres.setAlipayHandleTime(DateTimeUtil.getCurrentTimestamp());
		aqrccres.setAlipayTransId("");
		aqrccres.setError(model.getError());
		aqrccres.setIsSuccess(model.getIsSuccess());
		aqrccres.setPartnerTransId("");
		aqrccres.setQrCode(model.getQrCode());
		aqrccres.setQrCodeImgUrl(model.getQrCodeImgUrl());
		aqrccres.setResultCode(model.getResultCode());
		aqrccres.setSign(model.getSign());
		aqrccres.setSignType(model.getSignType());
		return aqrccres;
	}
}
